<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>编辑产品页</title> 
    
    <!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
 
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="/public/static/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/static/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/public/static/admin/css/animate.css" rel="stylesheet">
    <link href="/public/static/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <link href="/public/static/admin/css/ourstyle.css?v=4.0.0" rel="stylesheet">
    
</head>

<body class="fixed-sidebar full-height-layout gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>产品内容</h5>
                </div>
                <div class="ibox-content">
                    <div class="row">
                            <form action="{:url('Article/articleHandle')}" method="post" id="adsConFrom" class="form-horizontal">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">所属栏目：</label>
                                    <div class="col-sm-8">
                                        <select class="form-control" name="kind_id" id="kind_id">
                                        <?php echo $cat_select ?>
                                        </select>
                                    </div>
                                </div>
                                <!-- 商品属性-->
                                <!-- <div class="form-group">
                                <label class="col-sm-2 control-label">产品属性：</label>
                                <div class="col-sm-8">
                                    <div class="tab-pane" id="tab_product_attr">
                                        <table class="table table-bordered" id="product_attr_table">
                                        </table>
                                    </div>
                                </div>
                                </div> -->
                                <!-- 商品属性-->
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">产品标题：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="title" minlength="2" type="text" value="{$one.title}" required="" aria-required="true" placeholder="填写产品标题">
                                    </div>
                                </div> 
                                <div class="form-group" style="display:none">
                                    <label class="col-sm-2 control-label">英文标题：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="e_title" minlength="2" type="text" value="{$one.e_title}" required="" aria-required="true" placeholder="填写英文标题">
                                    </div>
                                </div>
                                <div class="form-group" style="display:none">
                                    <label class="col-sm-2 control-label">产品副标题：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="sub_title" minlength="2" type="text" value="{$one.sub_title}" required="" aria-required="true" placeholder="填写产品副标题">
                                    </div>
                                </div>
                                
                                <div class="form-group" style="display:none">
                                    <label class="col-sm-2 control-label">价格：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="shop_price" minlength="2" type="text" value="{$one.shop_price}" required="" aria-required="true" placeholder="填写价格">
                                    </div>
                                </div> 
                                <div class="form-group" style="display:none">
                                    <label class="col-sm-2 control-label">市场价格：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="market_price" minlength="2" type="text" value="{$one.market_price}" required="" aria-required="true" placeholder="填写市场价格">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">产品图片：<br/>（尺寸范围：0 ~ 521x265）</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <input type="text" class="form-control" name="thumb" id="thumb" value="{$one.thumb}" placeholder="" data-title=""> <span class="input-group-btn"> <button type="button" class="btn btn-primary" onclick="BrowseServer('thumb');">选择图片</button> </span>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">产品多图：<br/>（尺寸范围：0 ~ 580x370）</label>
                                    <div class="col-sm-8">
                                        <table class="table table-hover">
                                            <thead>
                                                <tr>
                                                    <th style="width:30%">图片</th>
                                                    <!-- <th>链接地址（必填）</th> -->
                                                    <th style="width:30%">图片标题</th>
                                                    <th style="width:80px;">序号</th>
                                                    <th style="width:80px">操作</th>
                                                </tr>
                                            </thead>
                                            <tbody id="SildeImgs">
                                                <tr>
                                                    <td><div class="input-group"><input type="text" class="form-control upload-path" id="slide_img_0" name="slide_img[]" value="" placeholder="请输入图片地址"><span class="input-group-btn"><button type="button" class="btn btn-primary" onclick="BrowseServer('slide_img_0')"><i class="fa fa-search"></i></button></span></div></td>
                                                    <!-- <td><input type="text" class="form-control" id="slide_link_0" name="slide_link[]" value="" placeholder="请输入链接地址"></td> -->
                                                    <td><input type="text" class="form-control" id="slide_alt_0" name="slide_alt[]" value="" placeholder="请输入图片标题"></td>
                                                    <td><input type="text" class="form-control" id="slide_order_0" name="slide_order[]" value="50" placeholder="请输入序号"></td>
                                                    <td><button type="button" class="btn btn-sm btn-success" onClick="addSlideRow();"><i class="fa fa-plus-square"></i> 添加</button></td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">产品说明：</label>
                                    <div class="col-sm-8">
                                        <textarea id="con1" name="con1" rows="2" cols="20">{$one.con1|htmlspecialchars_decode}</textarea>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">用法用量：</label>
                                    <div class="col-sm-8">
                                        <textarea id="con2" name="con2" rows="2" cols="20">{$one.con2|htmlspecialchars_decode}</textarea>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">适用人群：</label>
                                    <div class="col-sm-8">
                                        <textarea id="con3" name="con3" rows="2" cols="20">{$one.con3|htmlspecialchars_decode}</textarea>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">产品详情：</label>
                                    <div class="col-sm-8">
                                        <textarea id="content" name="content" rows="2" cols="20">{$one.content|htmlspecialchars_decode}</textarea>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">（手机端）产品详情：</label>
                                    <div class="col-sm-8">
                                        <textarea id="phone_content" name="phone_content" rows="2" cols="20">{$one.phone_content|htmlspecialchars_decode}</textarea>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">网页标题：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="web_title" type="text" class="configInput" value="{$one.web_title}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">文章关键词：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="keywords" type="text" class="configInput" value="{$one.keywords}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">文章描述：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="description" type="text" class="configInput" value="{$one.description}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">序号：</label>
                                    <div class="col-sm-8">
                                        <input class="configInput form-control" name="sort_order" type="text" class="configInput" value="{$one.sort_order}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">其他属性：</label>
                                    <div class="col-sm-8">
                                        <div class="col-sm-10">
                                            <label class="checkbox-inline i-checks">
                                            <input type="checkbox" name="is_tj" value="1"  {if $one['is_tj'] == 1} checked {/if}>推荐</label>
                                            <label class="checkbox-inline i-checks">
                                            <input type="checkbox" name="is_hide" value="1"  {if $one['is_hide'] == 1} checked {/if}>隐藏产品</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <input type="hidden" name="id" value="{$one.id}">
                                        <button class="btn btn-primary" onclick="ajax_submit_form('adsConFrom','{:url('Product/product_form')}')" type="button">保存</button>
                                    </div>
                                </div> 
                    	    </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

    <!-- 全局js -->
    <!-- <script src="/public/static/admin/js/jquery.min.js?v=2.1.4"></script> -->
    <script src="/public/static/admin/js/jQuery-2.1.4.min.js"></script>
    <script src="/public/static/admin/js/bootstrap.min.js?v=3.3.5"></script>
	<!-- 自定义js -->
    <script src="/public/static/admin/js/content.js?v=1.0.0"></script>
    <script src="/public/static/admin/js/plugins/layer/layer.min.js"></script>
    <script src="/public/static/admin/plugins/laydate/laydate.js"></script>
    <script src="/public/static/admin/js/article.js"></script> 
    <!-- iCheck -->
    <script src="/public/static/admin/js/plugins/iCheck/icheck.min.js"></script>
    <!-- CKeditor -->
    <script src="/public/static/admin/plugins/ckeditor/ckeditor.js"></script>
    <script type="text/javascript" src="/public/static/admin/plugins/ckfinder/ckfinder.js"></script> 
    <script language="javascript">
        editorReplace('content');
        editorReplace('phone_content');
        CKEDITOR.replace( 'con1', {  
            language : 'zh-cn',
            toolbar : [  
                ['Source'],  
                { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','-','RemoveFormat' ] },   
                { name: 'links', items : [ 'Link','Unlink' ] },    
                { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },  
            ],
            resize_enabled : true,  //是否可以自行拖拽编辑器大小  
            height : '100px',  
        }); 
        CKEDITOR.replace( 'con2', {  
            language : 'zh-cn',
            toolbar : [  
                ['Source'],  
                { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','-','RemoveFormat' ] },   
                { name: 'links', items : [ 'Link','Unlink' ] },    
                { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },  
            ],
            resize_enabled : true,  //是否可以自行拖拽编辑器大小  
            height : '100px',  
        }); 
        CKEDITOR.replace( 'con3', {  
            language : 'zh-cn',
            toolbar : [  
                ['Source'],  
                { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','-','RemoveFormat' ] },   
                { name: 'links', items : [ 'Link','Unlink' ] },    
                { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },  
            ],
            resize_enabled : true,  //是否可以自行拖拽编辑器大小  
            height : '100px',  
        }); 

        var htmlText = '<tr id="slideTR_{0}">';
        htmlText += '<td><div class="input-group"><input type="text" class="form-control upload-path" id="slide_img_{0}" name="slide_img[]" value="" placeholder="请输入图片地址"><span class="input-group-btn"><button type="button" class="btn btn-primary" onclick="BrowseServer(\'slide_img_{0}\')"><i class="fa fa-search"></i></button></span></div></td>';
        // htmlText += '<td><input type="text" class="form-control" id="slide_link_{0}" name="slide_link[]" value="" placeholder="请输入链接地址"></td>';
        htmlText += '<td><input type="text" class="form-control" id="slide_alt_{0}" name="slide_alt[]" value="" placeholder="请输入图片标题"></td>';
        htmlText += '<td><input type="text" class="form-control" id="slide_order_{0}" name="slide_order[]" value="50" placeholder="请输入序号"></td>';
        htmlText += '<td><button type="button" class="btn btn-sm btn-danger" onclick="delmySlideRow({0})"><i class="fa fa-minus-square"></i> 删除</button></td></tr>';
        var items = 1;

        function addSlideRow() {
            var lastitem = items - 1;
            var newHtmlTr = htmlText.replace(/\{0\}/g, items);
            $('#SildeImgs').append(newHtmlTr);
            items += 1;
        }
        function delmySlideRow(id) {
            $("#slideTR_" + id).remove();
        } 


        var jsonstr2 = '<?php echo $one['pics'] ?>';
        // console.log(jsonstr2);
        // $(function () {
            // $('.i-checks').iCheck({
            //     checkboxClass: 'icheckbox_square-green',
            //     radioClass: 'iradio_square-green',
            // });
            // DoPost("addAdsForm");
            FillAds(''+jsonstr2+'');
            //JS加载广告内容
            function FillAds(content) {
                // var json = eval(content);
                // var json = eval("("+content+")");
                var json = JSON.parse(content);
                // alert(content);
                // for(i=0;i<json.length;i++)
                for(var i in json)
                {
                    if(i ==0)
                    {
                        // $("#slide_width").val(json[0].width);
                        // $("#slide_height").val(json[0].height);
                    }
                    else
                    {
                        addSlideRow();//增加一行
                    }
                    $("#slide_img_"+i).val(json[i].image);
                    $("#slide_alt_"+i).val(json[i].alt);
                    $("#slide_order_"+i).val(json[i].order);
                    // $("#slide_icon_"+i).val(json[i].icon);
                }
            }
        // })

        CKEDITOR.on('instanceReady', function (ev) {
        var editor = ev.editor,
                dataProcessor = editor.dataProcessor,
                htmlFilter = dataProcessor && dataProcessor.htmlFilter;
        dataProcessor.writer.selfClosingEnd = '>';
        // Make output formatting behave similar to FCKeditor
        var dtd = CKEDITOR.dtd;
        for (var e in CKEDITOR.tools.extend({}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent)) {
            dataProcessor.writer.setRules(e,
                    {
                        indent: true,
                        breakBeforeOpen: true,
                        breakAfterOpen: false,
                        breakBeforeClose: !dtd[e]['#'],
                        breakAfterClose: true
                    });
        }
        // Output properties as attributes, not styles.
        htmlFilter.addRules(
                {
                    elements:
                    {
                        $: function (element) {
                            // Output dimensions of images as width and height
                            if (element.name == 'img') {
                                var style = element.attributes.style;
                                // delete element.attributes.style;//删除宽高
                            }

                            if (!element.attributes.style)
                                // delete element.attributes.style;//删除宽高
                            return element;
                        }
                    },
                    attributes:
                    {
                        style: function (value, element) {
                            // Return #RGB for background and border colors
                            //return convertRGBToHex(value);
                        }
                    }
                });
    });
    </script>
    <script>
        var index = parent.layer.getFrameIndex(window.name);
        function closethisdialog() {
            parent.layer.close(index);
        }

        $(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
            // DoPost("addAdsForm"); 
        }) 


    /** 以下 商品属性相关 js*/
    // $(document).ready(function(){
        
    //     // 商品类型切换时 ajax 调用  返回不同的属性输入框
    //     $("#kind_id").change(function(){        
    //         var product_id = $("input[name='id']").val();
    //         var kind_id = $(this).val();
    //             $.ajax({
    //                     type:'GET',
    //                     data:{product_id:product_id,kind_id:kind_id}, 
    //                     url:"/index.php/admin/Product/ajaxGetAttrInput",
    //                     success:function(data){                            
    //                             // $("#product_attr_table tr:gt(0)").remove();
    //                             $("#product_attr_table tr").remove();
    //                             $("#product_attr_table").append(data);
    //                     }        
    //             });                         
    //     });
    //     // 触发商品类型
    //     $("#kind_id").trigger('change');
    // });


    // // 属性输入框的加减事件
    // function addAttr(a)
    // {
    //     var attr = $(a).parent().parent().prop("outerHTML");    
    //     attr = attr.replace('addAttr','delAttr').replace('+','-');  
    //     $(a).parent().parent().after(attr);
    // }
    // // 属性输入框的加减事件
    // function delAttr(a)
    // {
    //    $(a).parent().parent().remove();
    // }
    </script>
</body>
</html>
